package com.yinNuo.collectWool.core.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;

/**
 * @author: yinNuo
 * create at: 2021/12/1 下午1:02
 * @description: 定时任务并发执行配置
 */
@Configuration
public class TheradConfiguration {
    @Bean
    public TaskScheduler taskScheduler() {
        ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
        //获取当前系统的核心线程数
        Integer i = Runtime.getRuntime().availableProcessors() + 1;
        taskScheduler.setPoolSize(i);
        taskScheduler.initialize();
        return taskScheduler;
    }

}
